package com.xiaobai.netease_news.model;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Android Studio
 * Project: Netease_News
 * Author: Jack
 * Email: jackfangqi1314@gmail.com/jackfangqi@163.com
 * Date: 2015/6/30
 */
public class HotPic {
    private String postid;
    private String series;
    private String desc;
    private String datatime;
    private String createdate;
    private List<Relatedid> relatedids;
    private String scover;
    private String autoid;
    private String url;
    private String creator;
    private List<Photo> photos;
    private String reporter;
    private String setname;
    private String cover;
    private String commenturl;
    private String source;
    private String settag;
    private String boardid;
    private String tcover;
    private String imgsum;

    public String getAutoid() {
        return autoid;
    }

    public String getBoardid() {
        return boardid;
    }

    public String getCommenturl() {
        return commenturl;
    }

    public String getCover() {
        return cover;
    }

    public String getCreatedate() {
        return createdate;
    }

    public String getCreator() {
        return creator;
    }

    public String getDatatime() {
        return datatime;
    }

    public String getDesc() {
        return desc;
    }

    public String getImgsum() {
        return imgsum;
    }

    public List<Photo> getPhotos() {
        return photos;
    }

    public String getPostid() {
        return postid;
    }

    public List<Relatedid> getRelatedids() {
        return relatedids;
    }

    public String getReporter() {
        return reporter;
    }

    public String getScover() {
        return scover;
    }

    public String getSeries() {
        return series;
    }

    public String getSetname() {
        return setname;
    }

    public String getSettag() {
        return settag;
    }

    public String getSource() {
        return source;
    }

    public String getTcover() {
        return tcover;
    }

    public String getUrl() {
        return url;
    }

    public void parseJson(JSONObject jsonObject) {
        if (jsonObject != null) {
            try {
                postid = jsonObject.getString("postid");
                series = jsonObject.getString("series");
                desc = jsonObject.getString("desc");
                datatime = jsonObject.getString("datatime");
                createdate = jsonObject.getString("createdate");
                scover = jsonObject.getString("scover");
                autoid = jsonObject.getString("autoid");
                url = jsonObject.getString("url");
                creator = jsonObject.getString("creator");
                reporter = jsonObject.getString("reporter");
                setname = jsonObject.getString("setname");
                cover = jsonObject.getString("cover");
                commenturl = jsonObject.getString("commenturl");
                source = jsonObject.getString("source");
                settag = jsonObject.getString("settag");
                boardid = jsonObject.getString("boardid");
                tcover = jsonObject.getString("tcover");
                imgsum = jsonObject.getString("imgsum");

                JSONArray array = jsonObject.getJSONArray("photos");
                photos = new ArrayList<>();
                for (int i = 0; i < array.length(); i++) {
                    JSONObject object = array.getJSONObject(i);
                    Photo photo = new Photo();
                    photo.parseJson(object);

                    photos.add(photo);
                }

//                JSONArray array1 = jsonObject.getJSONArray("relatedids");
//                for (int i = 0; i < array1.length(); i++) {
//                    JSONObject object = array1.getJSONObject(i);
//                    Relatedid relatedid = new Relatedid();
//                    relatedid.parseJson(object);
//                }

            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }
}
